//
//  TableCellTwoForCollectionViewFour.m
//  喜马拉雅FM
//
//  Created by dllo on 16/1/28.
//  Copyright © 2016年 lanou.com. All rights reserved.
//
#define WIDTH [UIScreen mainScreen].bounds.size.width
#import "TableCellTwoForCollectionViewFour.h"
#import "ModelForCollectionFour.h"
#import "UIImageView+WebCache.h"

@interface TableCellTwoForCollectionViewFour ()

@property (nonatomic, retain) UIImageView *picture;
@property (nonatomic, retain) UILabel *labelForTitle;
@property (nonatomic, retain) UILabel *labelForContentOne;
@property (nonatomic, retain) UILabel *labelForContentTwo;

@property (nonatomic, retain) NSMutableArray *arrForContent;

@end

@implementation TableCellTwoForCollectionViewFour

- (void)dealloc {

    [_picture release];
    [_labelForTitle release];
    [_labelForContentOne release];
    [_labelForContentTwo release];
    [_arrForContent release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.arrForContent = [NSMutableArray array];
        [self createSubViews];
    }
    return self;
}

- (void)createSubViews {
  
    self.picture = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"2.jpg"]];
    self.picture.frame = CGRectMake(10, 20, 100, 100);
    [self.contentView addSubview:self.picture];
    [self.picture release];
    
    
    self.labelForTitle = [[UILabel alloc]initWithFrame:CGRectMake(120, 20,200, 40)];
    [self.contentView addSubview:self.labelForTitle];
    self.labelForTitle.text = @"最火节目飙升榜";
    self.labelForTitle.font = [UIFont systemFontOfSize:22];
    [self.labelForTitle release];
    
    self.labelForContentOne = [[UILabel alloc]initWithFrame:CGRectMake(120, 67,WIDTH - 120 - 50, 25)];
    self.labelForContentOne.text = @"1 段子来了 | 这寒潮再不走, 那我可就";
    [self.contentView addSubview:self.labelForContentOne];
    self.labelForContentOne.font = [UIFont systemFontOfSize:18];
    self.labelForContentOne.textColor = [UIColor grayColor];
    [self.labelForContentOne release];
    
    self.labelForContentTwo = [[UILabel alloc]initWithFrame:CGRectMake(120, 95, WIDTH - 120 - 50, 25)];
    [self.contentView addSubview:self.labelForContentTwo];
    self.labelForContentTwo.text = @"2 贵族法则 第一章 骄傲的罗秀(新人播音)";
    self.labelForContentTwo.font = [UIFont systemFontOfSize:18];
    self.labelForContentTwo.textColor = [UIColor grayColor];
    [self.labelForContentTwo release];
    
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake([UIScreen mainScreen].bounds.size.width - 40, 55, 30, 30);
    [self.contentView addSubview:button];
    [button setImage:[UIImage imageNamed:@"you"] forState:UIControlStateNormal];
}

- (void)passModelForCellTwo:(ModelForCollectionFour *)model {
    
    [self.picture sd_setImageWithURL:[NSURL URLWithString:model.coverPath]];
    self.labelForTitle.text = model.title;

    [self.arrForContent removeAllObjects];

    ModelForCollectionFour *modelFirstResults = model;
    for (NSDictionary *dic in modelFirstResults.firstKResults) {
        NSString *str = [dic objectForKey:@"title"];
        [self.arrForContent addObject:str];

    }
    self.labelForContentOne.text = self.arrForContent[0];
    self.labelForContentTwo.text = self.arrForContent[1];

}

- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
